<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title></title>
		<script src="js/mui.min.js"></script>
		<link href="css/mui.min.css" rel="stylesheet" />
		<link href="css/login.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" charset="utf-8">
			mui.init();
		</script>
	</head>

	<body>
		<form class="mui-input-group adming_login_border admin_login_wrap">
			<div class="mui-input-row admin_items admin_input">
				<label>用 户 名</label>
				<input type="text" class="admin_input_style mui-input-clear" id="input_username" placeholder="请输入用户名">
			</div>

			<div class="mui-input-row admin_input">
				<label>密 码</label>
				<input type="password" class="mui-input-password admin_input_style" id="input_passwd" placeholder="请输入密码">
			</div>
			<div class="mui-input-row admin_input">
				<label>确 认 密 码</label>
				<input type="password" class="mui-input-password admin_input_style" id="input_rpasswd" placeholder="请再次输入密码" />
			</div>

		</form>
		<div class="mui-btn-row" align="middle">
			<br><br>
			<button id="submit" class="mui-btn mui-btn-primary btn btn-primary">注 册</button>
		</div>
		<script>
			var btn = document.getElementById("submit");
			btn.addEventListener("tap", function() {
				var username = document.getElementById("input_username").value
				var passwd = document.getElementById("input_passwd").value
				var rpasswd = document.getElementById("input_rpasswd").value
				if(passwd !== rpasswd) {
					mui.alert("两次密码输入不匹配")
					return
				}else if(username.length < 6 || username.length > 20 || passwd.length < 6 || passwd.length > 20) {
					mui.alert("帐号或密码长度应保持在6-20之间")
					return
				}

				mui.ajax("http://www.liwbiy.com:8080/Leisurelife/dealcmd", {
					type: "post",
					data: {
						cmd: 1,
						name: username,
						password: passwd,
					},
					timeout: 5000,
					success: function(data) {
						
						var json = eval('(' + data + ')')
						if(json.code!=null && json.code=="0") {
							//mui.alert("Success");
							localStorage.setItem("name",username);
							localStorage.setItem("token",json.uid);
							mui.openWindow("main.html");
						}
					},
					error: function(data) {
						mui.alert("网络连接出错")
					}
				})
			})
		</script>

	</body>

</html>